home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
Libraries
/
Dots & Pixels
/
sources
/
fullscreen.cp
< prev
next >
Wrap
Text File
|
1995-09-29
|
4KB
|
172 lines
#include <Windows.h>
#include <QDOffscreen.h>
#include <Fonts.h>
#include <Packages.h>
#include <SegLoad.h>
#include <ToolUtils.h>
#include <Palettes.h>
#include "general.h"
#include "port.h"
#include "window.h"
#include "depthChange.h"
#include "fullscreen.h"
int fullscreen::numInstances = 0;
short fullscreen::oldMBarHeight = 0;
short * const fullscreen::MBarHeight = (short *)0x0BAA;
PaletteHandle fullscreen::thePalette = (PaletteHandle) 0;
fullscreen::fullscreen( Boolean erase) : port(), depthChange()
{
makeOne( 0L, erase);
if( thePalette != 0)
{
SetPalette( myWindow, thePalette, false);
}
}
fullscreen::fullscreen( int bitDepth, Boolean erase)
: port(), depthChange( bitDepth)
{
makeOne( 0L, erase);
}
fullscreen::fullscreen( int bitDepth, CTabHandle theColorTable, Boolean erase)
: port(), depthChange( bitDepth)
{
makeOne( theColorTable, erase);
}
fullscreen::fullscreen( GDHandle theGDHandle, int bitDepth,
CTabHandle theColorTable, Boolean erase)
: port(), depthChange( bitDepth, theGDHandle)
{
SetGDevice( theGDHandle);
makeOne( theColorTable, erase);
}
void fullscreen::setentries( short start, short count, ColorSpec *theTable) const
{
use();
::SetEntries( start, count, theTable);
}
void fullscreen::makeOne( CTabHandle theColorTable, Boolean erase)
{
Rect rect;
myWindow = NewCWindow( &myWindowRecord, &rect, "\p", false, plainDBox, (WindowPtr)-1L, true, 0L);
MoveWindow( myWindow, qd.screenBits.bounds.left, qd.screenBits.bounds.top, true);
SizeWindow( myWindow, qd.screenBits.bounds.right - qd.screenBits.bounds.left,
qd.screenBits.bounds.bottom - qd.screenBits.bounds.top, false);
if( !erase)
{
short * const paintWhite = (short * const)0x09DC;
*paintWhite = 0;
}
ShowWindow( myWindow);
SetPort( myWindow);
/****************************************************/
/* Set the window's visRgn to include the menu bar. */
/****************************************************/
RectRgn( (*myWindow).visRgn, &qd.screenBits.bounds);
InvalRect( &qd.screenBits.bounds);
if( erase)
{
EraseRect( &qd.screenBits.bounds);
}
/*************************************************/
/* Set the global MBarHeight to 0 to prevent any */
/* other apps from writing to the menu bar. */
/*************************************************/
numInstances += 1;
if( numInstances == 1)
{
oldMBarHeight = *MBarHeight;
*MBarHeight = 0;
//
// Try to obtain the standard palette;
// don't worry when it is not found.
//
thePalette = GetNewPalette( 128);
}
GetGWorld( &myGWorldPtr, &myGDHandle);
if( theColorTable != 0)
{
unsigned char theState = HGetState( (Handle)theColorTable);
HLock( (Handle)theColorTable);
const short tableSize = (**theColorTable).ctSize;
ColorSpec *theColors = (**theColorTable).ctTable;
SetEntries( 0, tableSize, theColors);
HSetState( (Handle)theColorTable, theState);
//
// Also change the palette associated with the fullscreen window
// to consist of explicit colors only. Thus, one can use the
// palette manager's calls PmForeColor and PmBackColor to select
// the color value to write in the fullscreen's video memory.
// We pass 'tableSize + 1' since tableSize is zero-based.
//
myPalette = NewPalette(
tableSize + 1, theColorTable, pmExplicit, 0x0000);
SetPalette( myWindow, myPalette, false);
ActivatePalette( myWindow);
} else {
myPalette = 0;
}
#ifndef _APPL_
#ifndef THINK_CPLUS
//
// signal 'application' to close this window on exit
//
SetWRefCon( myWindow, 'vens');
#endif
#endif
myRect = myWindow->portRect;
myPix = (PixMapPtr)(&(myWindow->portBits));
}
fullscreen::~fullscreen()
{
CloseWindow( myWindow); // we passed our own WindowRecord => don't call DisposeWindow
numInstances -= 1;
//
// reset MBarHeight global variable if this was the last instance of 'fullscreen'
//
if( numInstances == 0)
{
*MBarHeight = oldMBarHeight;
if( thePalette != 0)
{
ReleaseResource( (Handle)thePalette);
thePalette = 0;
}
}
if( myPalette != 0)
{
DisposePalette( myPalette);
}
}
void fullscreen::show() const
{
ShowWindow( myWindow);
SelectWindow( myWindow);
}
void fullscreen::hide() const
{
HideWindow( myWindow);
}